<template>
  <div id="app">
    <router-view ></router-view>
  </div>
</template>

<script>

export default {
  name: 'App',
  data() {
    return {
      timer: ''
    }
  },
  methods: {
    // 在页面加载的时候获取 localStorage 中的数据
    getLoginMes() {
      const _isLogin = JSON.parse(localStorage.getItem('isLogin')) || ''
      const _userName = localStorage.getItem('userName') || ''
      const _endTime = localStorage.getItem('endTime') || ''
      if (_isLogin == true) {
        // console.log('已登录', _userName);
        this.$store.dispatch('isLogin')
        this.$store.dispatch('changeName', _userName)
        this.$store.dispatch('setEndTime', _endTime)
      }
    },
    // 判断登录是否过期
    loginIsEnd() {
      let timeOver = this.$store.state.endTime - Date.now()
      if (timeOver < 0) {
        this.$store.dispatch('noLogin')
        return
      }
    }
  },
  mounted() {
    this.getLoginMes()
    this.loginIsEnd()
  },
  
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
}

ul,
li {
  list-style: none;
}

body {
  margin: 0;
  padding: 0;
}

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center; */
  color: #2c3e50;
  /* margin-top: 60px; */
}


</style>
